package com.documents.common.util;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class AccessInterceptor implements Interceptor {
	public void destroy(){
	}
	
	public void init(){		
	}

	public String intercept(ActionInvocation actionInvocation) throws Exception {
		ActionContext actionContext = actionInvocation.getInvocationContext();
		String name = actionContext.getName();
//                System.out.print(name);
		Map session = actionContext.getSession();
		if((session.get("what") != null&&session.get("what").equals("true"))||name.equals("main")||name.equals("login")) {
                         return actionInvocation.invoke();
                }
               
		else  {
			return "login";
		}
		
	}

}
